package com.treasure.hunt.mine.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.module.lemlin.base.loadCircleImage
import com.treasure.hunt.R
import com.treasure.hunt.app.AppConstance
import com.treasure.hunt.entity.Buddy

class BuddyAdapter : BaseQuickAdapter<Buddy, BaseViewHolder>(R.layout.item_mine_buddy) {
    override fun convert(holder: BaseViewHolder, item: Buddy) {
        val isHttps: Boolean = item.avatar.substring(0, 5).contains("http") ||
                item.avatar.substring(0, 5).contains("https")
        holder.setText(R.id.tvBuddyNickname, item.nickname)
            .getView<ImageView>(R.id.ivBuddyImage)
            .loadCircleImage("${if (isHttps) "" else AppConstance.URL_IMAGE}${item.avatar}")
    }
}